﻿<cfsilent>
	<cfscript>
		
			sql = "SELECT sbj_name 
					FROM t_subject 
					WHERE sbj_id = :sbjId ";
					
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="sbjId", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" );
			
			rs_subjectEntity = queryObj.execute( sql=sql ).getResult();
	
			sql = "SELECT 
						DISTINCT term_index 
					FROM 
						t_schema 
					WHERE 
						grade = :grade 
						AND 
						(sbj_id = :subjectId OR sbj_id LIKE :subjectDirs ) 
					ORDER BY 
						term_index ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" );
			queryObj.addParam( name="subjectId", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="subjectDirs", value=event.getArg("SubID")&"_", cfsqltype="cf_sql_varchar" );
			
			rs_term = queryObj.execute( sql=sql ).getResult();
			
			event.setArg("pageTitle", "教学运行基础数据 - 培养方案修订 - 学期开课计划调整");

			dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
			mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");

			/* 初始化学期参数 */
			if ( not event.isArgDefined("Term") ) {
				event.setArg("Term", '01');
			}

			targetArgs = structNew();
			structInsert(targetArgs, "SubID", event.getArg("SubID"), true);
			structInsert(targetArgs, "Edition", event.getArg("Edition"), true);
			structInsert(targetArgs, "Schema", event.getArg("Schema"), true);
			structInsert(targetArgs, "Term", event.getArg("Term"), true);

			currentTab = event.getArg("TabID", "labTerm" & event.getArg("Term") );

			passArgs = structNew();
			structInsert(passArgs, "SubID", event.getArg("SubID"), true);
			structInsert(passArgs, "Edition", event.getArg("Edition"), true);
			structInsert(passArgs, "Schema", event.getArg("Schema"), true);

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>培养方案修订 - <cfoutput>#rs_subjectEntity.sbj_name#</cfoutput>专业(<cfoutput>#event.getArg("Edition")#</cfoutput>)版
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab2">
					<div class="tabLables">
                        <cfloop query="rs_term">
							<cfset structInsert(targetArgs, "Term", rs_term.term_index, true) />
							<a <cfif currentTab eq "labTerm"&rs_term.term_index>class="active"</cfif> href="<cfoutput>#buildURL('programSchemaWizardCourseByTerm', targetArgs)#</cfoutput>"><cfoutput>#mathAdvice.convertTermIdxToChinese(rs_term.term_index)#</cfoutput></a>
						</cfloop>
						<cfif rs_term.recordCount eq 0>
							<a class="active">一学期</a>
						</cfif>
					</div>
				</div>
				
				<div class="tabContentBox">
					
					<div class="noticeBlock">
						<div class="operation">
							<cfset structInsert(targetArgs, "Term", event.getArg("Term"), true) />
							<a class="uiButton " href="<cfoutput>#buildURL('programSchemaWizardCreateEntity', targetArgs)#</cfoutput>"><i class="mrs img btnAdd"></i><span class="uiButtonText">设置新课程</span></a>
						</div>
						<h3>专业课程开设情况</h3>
						<p><span class="img icon16x16 message"></span>如果您需要设置新的课程信息, 请通过上方的 "设置新课程" 按钮添加学期课程信息.</p>
					</div>
					
					<!--- 专业通用课程 --->
                    <cfset sql = "SELECT 
									  t_course.course_name,
									  t_course.course_credit, 
									  t_institute.institute_short, 
									  t_course_prop.prop_name, 
									  t_course_nature.cna_name, 
									  t_course.period_theory, 
									  t_course.period_practice, 
									  t_course.period_computer, 
									  t_schema.shm_id, 
									  t_course_prop.prop_id, 
									  t_course.course_code 
								  FROM 
									  t_schema 
									  INNER JOIN t_course ON t_course.cid = t_schema.cid 
									  INNER JOIN t_institute ON t_course.institute_id = t_institute.institute_id 
									  INNER JOIN t_course_prop ON t_course_prop.prop_id = t_schema.prop_id 
									  INNER JOIN t_course_nature ON t_course_nature.cna_id = t_schema.cna_id 
								  WHERE 
									  t_schema.grade = :grade 
									  AND 
									  t_schema.sbj_id = :subjectId 
									  AND 
									  t_schema.term_index = :term 
								  ORDER BY 
									  t_course_nature.cna_name, t_course_prop.prop_name, t_course.course_name " />
                                      
					<cfset queryObj = new query( datasource=application.dnsSlave ) />
					<cfset queryObj.addParam( name="term", value=event.getArg("Term"), cfsqltype="cf_sql_char" ) />
                    <cfset queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" ) />
                    <cfset queryObj.addParam( name="subjectId", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" ) />
                    
					<cfset rs_schema = queryObj.execute( sql=sql ).getResult() />
                    
					<cfset row = 0 />

					<cfif rs_schema.recordCount>
						<table class="UItable">
							<tr>
								<td align="center" width="22" class="cellBorder">专业通用</td>
								<td align="center" class="cellBorder">
									<table class="UIEditable">
										<thead>
											<tr>
												<td width="48">类别</td>
												<td width="48">课程性质</td>
												<td width="80">课程号</td>
												<td align="left">课程</td>
												<td width="24" align="right">理论</td>
												<td width="24" align="right">实践</td>
												<td width="24" align="right">上机</td>
												<td width="24" align="right">学分</td>
												<td width="48">开课学院</td>
												<td width="18"></td>
											</tr>
										</thead>
										<tbody>
                                            <cfloop query="rs_schema">
												<cfset structInsert(passArgs, "ID", rs_schema.shm_id, true) />
												<cfset row++ />
												<tr class="editRows">
													<td><cfoutput>#rs_schema.cna_name#</cfoutput></td>
													<td><cfoutput>#rs_schema.prop_name#</cfoutput></td>
													<td><span class="numeric"><cfoutput>#rs_schema.course_code#</cfoutput></span></td>
													<td align="left"><span class="notice"><cfif rs_schema.prop_id eq '1'>※</cfif></span><cfoutput>#rs_schema.course_name#</cfoutput></td>
													<td align="right"><cfif rs_schema.period_theory gt 0><span class="numeric"><cfoutput>#rs_schema.period_theory#</cfoutput></span></cfif></td>
													<td align="right"><cfif rs_schema.period_practice gt 0><span class="numeric"><cfoutput>#rs_schema.period_practice#</cfoutput></span></cfif></td>
													<td align="right"><cfif rs_schema.period_computer gt 0><span class="numeric"><cfoutput>#rs_schema.period_computer#</cfoutput></span></cfif></td>
													<td align="right"><span class="numeric"><cfoutput>#numberFormat(rs_schema.course_credit,'_._')#</cfoutput></span></td>
													<td align="right"><cfoutput>#rs_schema.institute_short#</cfoutput></td>
													<td><a class="operation" href="<cfoutput>#buildURL('programSchemaWizardModifyEntity', passArgs)#</cfoutput>"></a></td>
												</tr>
											</cfloop>
										</tbody>
									</table>
								</td>
							</tr>
						</table>
					</cfif>
					
					<cfset structDelete(passArgs, "ID", false) />
					
					<!--- 专业方向课程 --->
                    
                    <!--- 专业通用课程 --->
                    <cfset sql = "SELECT 
										t_schema.sbj_id, t_subject.sbj_short, COUNT(*) count 
									FROM 
										t_schema 
										INNER JOIN t_subject ON t_subject.sbj_id = t_schema.sbj_id 
									WHERE 
										t_schema.grade = :grade 
										AND 
										t_schema.term_index = :term 
										AND 
										t_schema.sbj_id LIKE :subjectDirs 
									GROUP BY 
										t_schema.sbj_id, t_subject.sbj_short 
									ORDER BY 
										t_subject.sbj_short  " />
                                        
					<cfset queryObj = new query( datasource=application.dnsSlave ) />
					<cfset queryObj.addParam( name="term", value=event.getArg("Term"), cfsqltype="cf_sql_char" ) />
                    <cfset queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" ) />
                    <cfset queryObj.addParam( name="subjectDirs", value=event.getArg("SubID")&"_", cfsqltype="cf_sql_varchar" ) />
                    
					<cfset rs_dir = queryObj.execute( sql=sql ).getResult() />

                    <cfloop query="rs_dir">
						
                        <cfset sql = "SELECT 
											t_course.course_name,
											t_course.course_credit, 
											t_institute.institute_short, 
											t_course_prop.prop_name, 
											t_course_nature.cna_name, 
											t_course.period_theory, 
											t_course.period_practice, 
											t_course.period_computer, 
											t_schema.shm_id, 
											t_course_prop.prop_id, 
											t_course.course_code 
										FROM 
											t_schema 
											INNER JOIN t_course ON t_course.cid = t_schema.cid 
											INNER JOIN t_institute ON t_course.institute_id = t_institute.institute_id 
											INNER JOIN t_course_prop ON t_course_prop.prop_id = t_schema.prop_id 
											INNER JOIN t_course_nature ON t_course_nature.cna_id = t_schema.cna_id 
										WHERE 
											t_schema.grade = :grade 
											AND 
											t_schema.sbj_id = :subjectId 
											AND 
											t_schema.term_index = :term 
										ORDER BY 
											t_course_nature.cna_name, t_course_prop.prop_name, t_course.course_name " />
                                            
						<cfset queryObj = new query( datasource=application.dnsSlave ) />
						<cfset queryObj.addParam( name="term", value=event.getArg("Term"), cfsqltype="cf_sql_char" ) />
						<cfset queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" ) />
						<cfset queryObj.addParam( name="subjectId", value=rs_dir.sbj_id, cfsqltype="cf_sql_varchar" ) />
                        
						<cfset rs_schema = queryObj.execute( sql=sql ).getResult() />
                    
						<cfset row = 0 />
						
						<table class="UItable">
							<tr>
								<td align="center" width="22" class="cellBorder"><cfoutput>#rs_dir.sbj_short#</cfoutput></td>
								<td align="center" class="cellBorder">
									<cfif rs_schema.recordCount>
										<table class="UIEditable">
											<thead>
												<tr>
													<td width="48">类别</td>
													<td width="48">课程性质</td>
													<td width="80">课程号</td>
													<td align="left">课程</td>
													<td width="24" align="right">理论</td>
													<td width="24" align="right">实践</td>
													<td width="24" align="right">上机</td>
													<td width="24" align="right">学分</td>
													<td width="48">开课学院</td>
													<td width="18"></td>
												</tr>
											</thead>
											<tbody>
												<cfloop query="rs_schema">
												<cfset structInsert(passArgs, "ID", rs_schema.shm_id, true) />
												<cfset row++ />
												<tr class="editRows">
													<td><cfoutput>#rs_schema.cna_name#</cfoutput></td>
													<td><cfoutput>#rs_schema.prop_name#</cfoutput></td>
													<td><span class="numeric"><cfoutput>#rs_schema.course_code#</cfoutput></span></td>
													<td align="left"><span class="notice"><cfif rs_schema.prop_id eq '1'>※</cfif></span><cfoutput>#rs_schema.course_name#</cfoutput></td>
													<td align="right"><cfif rs_schema.period_theory gt 0><span class="numeric"><cfoutput>#rs_schema.period_theory#</cfoutput></span></cfif></td>
													<td align="right"><cfif rs_schema.period_practice gt 0><span class="numeric"><cfoutput>#rs_schema.period_practice#</cfoutput></span></cfif></td>
													<td align="right"><cfif rs_schema.period_computer gt 0><span class="numeric"><cfoutput>#rs_schema.period_computer#</cfoutput></span></cfif></td>
													<td align="right"><span class="numeric"><cfoutput>#numberFormat(rs_schema.course_credit,'_._')#</cfoutput></span></td>
													<td align="right"><cfoutput>#rs_schema.institute_short#</cfoutput></td>
													<td><a class="operation" href="<cfoutput>#buildURL('programSchemaWizardModifyEntity', passArgs)#</cfoutput>"></a></td>
												</tr>
											</cfloop>
											</tbody>
										</table>
									</cfif>
								</td>
							</tr>
						</table>
						
						<cfset structDelete(passArgs, "ID", false) />

						
					</cfloop>
					
				</div>
				
				
			</div>
		</li>
	</ul>
</div>
				
				

